<template>
  <div class="demo-container">
    <h2>Slotted FanCarousel Demo</h2>
    
    <!-- 示例 1: 使用默认插槽内容（BeforeAfterSlider） -->
    <section class="demo-section">
      <h3>默认插槽内容（BeforeAfterSlider）</h3>
      <FanCarousel 
        :items="carouselImages"
        :autoPlay="true"
        :autoPlayInterval="5000"
        @slideChange="handleSlideChange"
        @itemClick="handleItemClick"
      />
    </section>

    <!-- 示例 2: 使用自定义插槽内容（简单图片） -->
    <section class="demo-section">
      <h3>自定义插槽内容（简单图片）</h3>
      <FanCarousel 
        :items="simpleImages"
        :autoPlay="false"
        @slideChange="handleSlideChange"
        @itemClick="handleItemClick"
      >
        <template #item="{ item, index, isActive, onClick }">
          <div 
            class="simple-image-card"
            :class="{ active: isActive }"
            @click="onClick"
          >
            <img :src="item.image" :alt="item.alt" />
            <div class="overlay">
              <h4>{{ item.title }}</h4>
              <p>{{ item.description }}</p>
            </div>
          </div>
        </template>
      </FanCarousel>
    </section>

    <!-- 示例 3: 使用自定义插槽内容（卡片式） -->
    <section class="demo-section">
      <h3>自定义插槽内容（卡片式）</h3>
      <FanCarousel 
        :items="cardImages"
        :autoPlay="false"
        @slideChange="handleSlideChange"
        @itemClick="handleItemClick"
      >
        <template #item="{ item, index, isActive, onClick }">
          <div 
            class="card-item"
            :class="{ active: isActive }"
            @click="onClick"
          >
            <div class="card-header">
              <div class="card-icon" :style="{ backgroundColor: item.color }">
                {{ item.icon }}
              </div>
              <h4>{{ item.title }}</h4>
            </div>
            <div class="card-content">
              <p>{{ item.description }}</p>
              <div class="card-stats">
                <span>{{ item.stat1 }}</span>
                <span>{{ item.stat2 }}</span>
              </div>
            </div>
          </div>
        </template>
      </FanCarousel>
    </section>

    <!-- 示例 4: 自定义 BeforeAfterSlider 配置 -->
    <section class="demo-section">
      <h3>自定义 BeforeAfterSlider 配置</h3>
      <FanCarousel 
        :items="carouselImages"
        :autoPlay="false"
        @slideChange="handleSlideChange"
        @itemClick="handleItemClick"
      >
        <template #item="{ item, index, isActive, onClick }">
          <BeforeAfterSlider
            :before-image="item.beforeImage"
            :after-image="item.afterImage"
            :before-alt="item.beforeAlt"
            :after-alt="item.afterAlt"
            width="100%"
            height="100%"
            :show-animation="isActive"
            :animation-duration="1.5"
            :show-tag="true"
            tag-text="自定义效果"
            border-radius="20px"
            @imageClick="onClick"
          />
        </template>
      </FanCarousel>
    </section>
  </div>
</template>

<script>
import FanCarousel from '@/components/carousel/FanCarousel.vue'
import BeforeAfterSlider from '@/components/BeforeAfterSlider.vue'

export default {
  name: 'SlottedCarouselDemo',
  components: {
    FanCarousel,
    BeforeAfterSlider
  },
  data() {
    return {
      carouselImages: [
        {
          beforeImage: require('@/assets/images/carousel/1before.jpg'),
          afterImage: require('@/assets/images/carousel/1after.jpg'),
          beforeAlt: '人像原图',
          afterAlt: '人像美化后'
        },
        {
          beforeImage: require('@/assets/images/carousel/1.1before.jpg'),
          afterImage: require('@/assets/images/carousel/1.1after.jpg'),
          beforeAlt: '风景原图',
          afterAlt: '风景调色后'
        },
        {
          beforeImage: require('@/assets/images/carousel/1.2before.jpg'),
          afterImage: require('@/assets/images/carousel/1.2after.jpg'),
          beforeAlt: '产品原图',
          afterAlt: '产品修图后'
        }
      ],
      simpleImages: [
        {
          image: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=400&h=600',
          alt: '山景',
          title: '壮丽山景',
          description: '体验大自然的震撼'
        },
        {
          image: 'https://images.unsplash.com/photo-1439066615861-d1af74d74000?w=400&h=600',
          alt: '湖景',
          title: '宁静湖景',
          description: '感受湖水的宁静'
        },
        {
          image: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=400&h=600',
          alt: '森林',
          title: '神秘森林',
          description: '探索森林的奥秘'
        }
      ],
      cardImages: [
        {
          icon: '📈',
          title: '数据分析',
          description: '深度洞察您的业务数据，提供专业的分析报告',
          color: '#FF6B35',
          stat1: '99%准确率',
          stat2: '实时更新'
        },
        {
          icon: '🎨',
          title: '创意设计',
          description: '专业的设计团队为您打造独特的视觉体验',
          color: '#4ECDC4',
          stat1: '1000+案例',
          stat2: '24h响应'
        },
        {
          icon: '🚀',
          title: '快速部署',
          description: '一键部署您的项目，快速上线运行',
          color: '#45B7D1',
          stat1: '5分钟部署',
          stat2: '99.9%稳定'
        }
      ]
    }
  },
  methods: {
    handleSlideChange(index) {
      console.log('Slide changed:', index)
    },
    
    handleItemClick(data) {
      console.log('Item clicked:', data)
    }
  }
}
</script>

<style scoped>
.demo-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.demo-container h2 {
  text-align: center;
  color: white;
  margin-bottom: 40px;
  font-size: 2em;
}

.demo-section {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 40px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.demo-section h3 {
  color: white;
  margin-bottom: 20px;
  text-align: center;
}

/* 简单图片卡片样式 */
.simple-image-card {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
}

.simple-image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.simple-image-card .overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  color: white;
  padding: 20px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.simple-image-card.active .overlay,
.simple-image-card:hover .overlay {
  transform: translateY(0);
}

.simple-image-card h4 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: bold;
}

.simple-image-card p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
}

/* 卡片样式 */
.card-item {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(10px);
}

.card-item.active {
  transform: scale(1.02);
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.card-header {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-right: 12px;
}

.card-header h4 {
  margin: 0;
  color: #333;
  font-size: 18px;
  font-weight: 600;
}

.card-content p {
  color: #666;
  line-height: 1.5;
  margin-bottom: 15px;
  font-size: 14px;
}

.card-stats {
  display: flex;
  justify-content: space-between;
}

.card-stats span {
  background: rgba(0,0,0,0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  color: #555;
  font-weight: 500;
}
</style>